package com.lee.jdbc;

import java.util.List;

import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.lee.jdbc.dao.trans2.StudentDao;

public class TransTest2 {

	@Test
	public void testTransaction() {
		// 声明式事务
		ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("jdbcdemo2.xml");
		StudentDao studentJdbcTemplate = (StudentDao)context.getBean("studentJdbcTransTemplate");
		System.out.println("-------------- creating ----------------");
		studentJdbcTemplate.create("Zala", 15, 80, 2020);
		studentJdbcTemplate.create("Ayan", 19, 99, 2019);
		studentJdbcTemplate.create("Jila", 21, 98, 2020);
		System.out.println("-------------- query ----------------");
		List<StudentMarks> studentMarks = studentJdbcTemplate.listStudents();
		for (StudentMarks marks : studentMarks) {
			System.out.println(marks);
		}

		context.close();
	}
}
